<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <style>
      .container {
        width: 500px;
        height: 300px;
        margin: 100px auto;
        position: relative;
        overflow: hidden;
      }
      .div1,
      .div2 {
        width: 100%;
        height: 300px;
        position: absolute; /*相对定位和绝对定位结合 让两个背景相互重叠 */
        top: 0;
        left: 0;
        background-color: rgb(0, 0, 0);
        background-color: rgb(255, 255, 255);
        background-color: rgb(255, 0, 0);
        background-color: rgba(255, 0, 0, 0); /*全透明*/
        background-color: rgba(255, 0, 0, 0.5);
      }
      .div1 {
        background-image: url(./CSS3背景/images/bg.png);
      }
      .div2 {
        /*background-color: rgba(0,0,255,0.5);*/
        background-color: hsl(120, 50%, 50%);
        /*background-color: hsla(120,50%,50%,0.7);*/
      }
      .div2:hover {
        background-color: hsla(
          180,
          50%,
          50%,
          0.5
        ); /*通常用这个方法设置元素的蒙版层*/
      }
    </style>
  </head>
  <body>
    <div class="container">
      <div class="div1"></div>
      <div class="div2"></div>
    </div>
  </body>
</html>
